//package com.vf.admin.common.db.SqlUitls;
//
//import java.beans.IntrospectionException;
//import java.lang.reflect.Field;
//import java.lang.reflect.InvocationTargetException;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.HashMap;
//import java.util.Map;
//
//import com.vf.admin.common.db.utils.PojoBySql;
//import org.apache.log4j.Logger;
//
//
///**
// * 进行insert语句的执行
// *
// */
//public class InsertSql {
//	private Logger log = Logger.getLogger(InsertSql.class);
//	public static InsertSql getInstance(){
//		return new InsertSql();
//	}
//
//
//	/**
//	 * 对象进行保存操作
//	 * @param obj
//	 * @throws SQLException
//	 * @throws IllegalAccessException
//	 * @throws InvocationTargetException
//	 * @throws NoSuchMethodException
//	 * @throws InstantiationException
//	 * @throws IntrospectionException
//	 */
//	public int save(Object obj){
//		try{
//			PojoBySql pojobysql = PojoBySql.class.newInstance();
//			PojoConverSql.getInstance().pojoBySql(obj, pojobysql);
//			//拼接sql
//			StringBuffer columnName = new StringBuffer();
//			StringBuffer columnDataValue = new StringBuffer();
//			for(Map.Entry<String, Object> entry: pojobysql.getColumnDateMap().entrySet()) {
//				columnName.append(entry.getKey()+",");
//				columnDataValue.append("?"+",");
//			}
//			String sql = "insert into "+pojobysql.getTableName() + "("+columnName.substring(0,columnName.length()-1)
//					+ ") values(" + columnDataValue.substring(0,columnDataValue.length()-1)+ ")";
//
//			System.out.println("保存sql:" + sql);
//			log.info("保存sql:" + sql);
//
//
////			PreparedStatement ps = DbUtils.getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
//////			PreparedStatement ps = DbUtils.getConnection().prepareStatement(sql);
////			int j = 1;
////			for(Map.Entry<String, Object> entry: pojobysql.getColumnDateMap().entrySet()) {
////				Object valueobj = pojobysql.getColumnDateMap().get(entry.getKey());
////				ps.setObject(j, valueobj);
////				j++;
////			}
////			ps.executeUpdate();
////			String indexcolumn = pojobysql.getIndexName();
////			if(indexcolumn!=null && !indexcolumn.trim().equals("null") && !indexcolumn.trim().equals("")){
////				ResultSet rs=ps.getGeneratedKeys();
////				int  rowCount = rs.getRow();
////				if (rs.next()){
////					return rs.getInt(1);
////		        }else{
////		        	return 0;
////		        }
////			}else{
////				return 0;
////			}
//		}catch(Exception e){
//			e.printStackTrace();
//		}
//		return 0;
//	}
////	/**
////	 * 把pojo实体对象转换成插入的sql
////	 *
////	 * @throws NoSuchMethodException
////	 * @throws InvocationTargetException
////	 * @throws IllegalAccessException
////	 * @throws SQLException
////	 * @throws IntrospectionException
////	 */
////	private void pojoBySql(Object obj,PojoBySql pojobysql) throws IllegalAccessException,
////			InvocationTargetException, NoSuchMethodException, SQLException, IntrospectionException {
////		Class clas = obj.getClass();
////		String clasName = clas.getName();
////		String tableName = "";
////
////		HashMap<String, String> objTableMap = new HashMap<String, String>();
////		HashMap<String, Object> columnDateMap = new HashMap<String, Object>();
////
////		//类名称
////		if (clasName.indexOf(".") >= 0) {
////			clasName = clasName.substring(clasName.lastIndexOf(".") + 1,clasName.length());
////			tableName = clasName;    //表名称做注解则默:类名为表名称
////		}
////
////		//类名称对应的表名称
////		if(clas.isAnnotationPresent(Table.class)){
////			Table table = (Table) clas.getAnnotation(Table.class);    //该class存在Table类型的注解，获取指定的表名
////			tableName = table.name();
////		}
////
////		Field[] fieldArray = clas.getDeclaredFields();
////		for (Field  field : fieldArray) {
////			String name = field.getName(); //成员变量名
////			Class type = field.getType(); //成员变量类型
////			Object data = new PropertyUtilsBean().getNestedProperty(obj, name);    //成员变量值
////			String coluName = name;    //如果字段没有注解默认为成员变量名
////			int coluLength = 32;    //默认为32位长度
////			boolean coluindex = false;//是否主键
////
////			if(field.isAnnotationPresent(Column.class)){
////				Column column = field.getAnnotation(Column.class);//获取成员变量的注解实例
////				//获取元素值
////				coluName = column.name();    //变量对应的注解中的表字段名称
////				coluLength = column.length();
////				coluindex = column.index();//
////			}
////
////			columnDateMap.put(coluName,data);    //字段名称-值
////		}
////		pojobysql.setTableName(tableName);
////		pojobysql.setColumnDateMap(columnDateMap);
////	}
//}
